#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/10/18 22:39
# @File     : kc16_33.py
# @Project  : CSPT
def parse_33_Operational_Platform_Remote_Control_Start_Charging_Response(body):
    # 解析0x25 充电过程 BMS 信息
    data = {
        "交易流水号": f"{body[0:32]}({body[0:32]})",
        "桩编号": f"{body[32:46]}({body[32:46]})",
        "枪号": f"{int(body[46:48], 16)}枪({body[46:48]})",
        "启动结果": f"{start_result(body[48:50])}({body[48:50]})",
        "失败原因": f"{fail_reason(body[50:52])}({body[50:52]})",
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def start_result(result):
    return "失败" if result == "00" else "成功" if result == "01" else "未知"


def fail_reason(result):
    return "无" if result == "00" else "设备编号不匹配" if result == "01" else "枪已在充电" if result == "02" \
        else "设备故障" if result == "03" else "设备离线" if result == "04" else "未插枪" if result == "05" else "未知"


__all__ = ['parse_33_Operational_Platform_Remote_Control_Start_Charging_Response']
